<!-- crawler/templates/registration/login.html -->
{% extends "base.html" %}
{% block content %}
<div class="container">
  <div class="row justify-content-center mt-5">
    <div class="col-md-6 col-lg-4">
      <div class="card shadow">
        <div class="card-header bg-primary text-white">
          <h3 class="mb-0 text-center">{{ system_name }}登录</h3>
        </div>
        <div class="card-body">
          <form method="post" action="{% url 'login' %}">
            {% csrf_token %}

            <div class="mb-3">
              <label class="form-label">用户名</label>
              <input type="text"
                     name="username"
                     class="form-control"
                     required
                     autofocus>
            </div>

            <div class="mb-4">
              <label class="form-label">密码</label>
              <input type="password"
                     name="password"
                     class="form-control"
                     required>
            </div>

            <button type="submit" class="btn btn-primary w-100">登录</button>

            {% if form.errors %}
            <div class="alert alert-danger mt-3">
              用户名或密码错误！
            </div>
            {% endif %}

            <!-- 添加注册跳转链接 -->
            <div class="text-center mt-3">
              <a href="{% url 'register' %}"
                 class="btn btn-success w-100">
                立即注册新账号
              </a>
            </div>

            <input type="hidden" name="next" value="{{ next }}">
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}